home *** CD-ROM | disk | FTP | other *** search
- Subject: v16i065: Front end editor program, Part05/05
- Newsgroups: comp.sources.unix
- Sender: sources
- Approved: rsalz@uunet.UU.NET
-
- Submitted-by: Kazumasa Utashiro <kddlab!sra.junet!utashiro>
- Posting-number: Volume 16, Issue 65
- Archive-name: fep/part05
-
- #!/bin/sh
- # to extract, remove the header and type "sh filename"
- if `test ! -s ./Makefile`
- then
- echo "writing ./Makefile"
- cat > ./Makefile << '\End\Of\File\'
- #
- # Copyright (c) 1987, 1988 by Software Research Associates, Inc.
- #
- # $Header: Makefile,v 4.0 88/08/05 20:24:19 utashiro Exp $
- #
- # Options:
- # KANJI: SHIFT-JIS kanji code handling on ASCII KANJI UNIX
- #
- TARGET = fep
- HEADER = fep_defs.h fep_glob.h fep_funcs.h fep_stat.h
- SRC = fep_main.c fep_edit.c fep_hist.c fep_com.c fep_funcs.c fep_set.c \
- fep_vi.c fep_util.c fep_alias.c
- OBJ = fep_main.o fep_edit.o fep_hist.o fep_com.o fep_funcs.o fep_set.o \
- fep_vi.o fep_util.o fep_alias.o
- DISTRIBUTION\
- = Makefile fep.1 $(HEADER) $(SRC) feprc.sample README
-
- INSTDIR = /usr/local/bin
-
- #STAT = -DSTAT# Delete # for statistic info
- #KANJI = -DKANJI# Delete # for KANJI handling
- CONFIG = $(STAT) $(KANJI)
-
- DEBUG = -g
- #DEBUG = -O
-
- CFLAGS = $(DEBUG) $(CONFIG)
- LDFLAGS = -ltermlib
-
- all: $(TARGET)
-
- $(TARGET): $(OBJ)
- $(CC) -o $(TARGET) $(CFLAGS) $(OBJ) $(LDFLAGS)
-
- argv: fep_com.c
- $(CC) -o argv -DMKARGDEBUG fep_util.c
-
- install: $(TARGET)
- install -s $(TARGET) $(INSTDIR)
- install -c fep.1 /usr/man/manl/fep.l
-
- README.jis: README
- jcat -IJ README > $@
-
- # rogue-monster version shar
- shar: fep.shr1
-
- TARGETSIZE=40000
- fep.shr1: $(DISTRIBUTION)
- shar -f fep -m $(TARGETSIZE) $(DISTRIBUTION)
-
- # tektronix shar
- tshar: $(DISTRIBUTION)
- shar $(DISTRIBUTION) > fep.shar
-
- clean:
- rm -f *.o $(TARGET)
-
- distversion: $(DISTRIBUTION)
- @ident $(DISTRIBUTION) | grep Header
-
- fep_main.o: fep_defs.h fep_glob.h fep_funcs.h fep_stat.h
- fep_com.o: fep_defs.h fep_glob.h fep_funcs.h
- fep_edit.o: fep_defs.h fep_glob.h fep_funcs.h
- fep_funcs.o: fep_funcs.h
- fep_hist.o: fep_defs.h fep_glob.h fep_funcs.h
- fep_set.o: fep_defs.h fep_glob.h
- fep_util.o: fep_defs.h
- fep_vi.o: fep_defs.h fep_glob.h fep_funcs.h
- \End\Of\File\
- else
- echo "will not over write ./Makefile"
- fi
- if `test ! -s ./fep.1`
- then
- echo "writing ./fep.1"
- cat > ./fep.1 << '\End\Of\File\'
- .\" Copyright (c) 1987, 1988 by Software Research Associates, Inc.
- .\" $Header: fep.1,v 4.0 88/08/05 20:22:31 utashiro Rel $
- .TH FEP 1L "5 Aug 1988" "SRA Distribution"
- .SH NAME
- fep \(em general purpose front end processor
- .SH SYNOPSIS
- \fBfep\fR [\|-\fBemacs\fR\||\|-\fBvi\fR\|] \fI\s-1UNIX\s0-command\fR
- .SH DESCRIPTION
- .I Fep
- is a general purpose front end processor applicable to most UNIX commands
- that features \fIvi\fP\|(1)- or \fIemacs\fR\|(1)-like line editing and
- a command history mechanism like that of \fIcsh\fR\|(1).
- .PP
- Choice of editing style is made by selecting either
- the emacs mode or the vi mode
- (named for the editors they emulate),
- specified either by command line option or
- by setting a variable interactively or in the start-up file
- or environment EDITMODE (see editmode variable).
- .PP
- The default key bindings are shown below for both edit modes.
- These can be customized using the fep-bind command.
- .PP
- .B Emacs Bindings
- .PP
- Here follow the default key bindings for the emacs mode.
- Each function name should be self-explanatory.
- The function names are defined as similarly to Gosling's emacs as possible.
- .sp
- .RS
- .nf
- .ta 1.5i
- ^@ mark
- ^A beginning-of-line
- ^B backward-character
- ^D delete-next-character
- ^E end-of-line
- ^F forward-character
- ^I insert-tab
- ^J new-line
- ^K kill-to-end-of-line
- ^L clear-screen
- ^M new-line
- ^N next-history
- ^P previous-history
- ^T previous-history
- ^Y yank-from-kill-buffer
- ^^ toggle-transparency
- ^X-^B show-bindings
- ^X-^H show-history
- ^X-^C terminate
- ^X-^D send-eof
- ^X-^L repaint
- ^X-( start-script
- ^X-) end-script
- esc-b backward-word
- esc-B backward-word
- esc-d delete-next-word
- esc-D delete-next-word
- esc-f forward-word
- esc-F forward-word
- esc-h delete-previous-word
- esc-H delete-previous-word
- esc-l list-file-name
- esc-L list-file-name
- esc-esc expand-file-name
- esc-? help
- esc-_ invoke-shell
- esc-< search-reverse
- esc-> search-forward
- .if t .sp .3v
- /* Bindings inherited from the tty driver */
- .if t .sp .3v
- erase delete-previous-character
- kill delete-line
- rprnt reprint
- werase delete-previous-word
- lnext literal-next
- .fi
- .RE
- .sp
- .B Vi bindings
- .PP
- The vi mode has two sub-modes,
- the command mode and the text insert mode.
- The commands of vi are emulated as correctly as possible.
- Here is a list of the default key bindings of the vi mode
- that differ from normal vi commands.
- The tty driver control characters are also inherited in this mode.
- .sp
- .RS
- .nf
- n search-reverse
- N search-forward
- ^A expand-file-name
- ^L list-file-name
- ^N next-history
- ^P previous-history
- ^R reprint
- ^^ toggle-transparency
- ^X-^B show-bindings
- ^X-^H show-history
- ^X-^L repaint
- ^X-^X expand-file-name
- ^X-^C terminate
- ^X-^D send-eof
- ^X-l list-file-name
- ^X-L list-file-name
- ^X-? help
- ^X-( start-script
- ^X-) end-script
- .fi
- .RE
- .sp
- .B Built-in commands
- .PP
- .I Fep
- has some built-in commands
- that are not passed to the child process but
- understood and processed by fep itself.
- These commands can be issued from the terminal or from the start-up file.
- .RS 3n
- .IP "\fBfep-bind \fIfunction-name key-binding\fR"
- Change key bindings.
- For example,
- to bind the function
- .I list-file-name
- to the string "^X-^X",
- type the following:
- .if t .sp 0.3v
- .if n .sp 1
- \h'\w'MMMMM'u'fep-bind list-file-name "\\^X\\^X"
- .if t .sp 0.3v
- .if n .sp 1
- .PP
- .nf
- \fBfep-alias\fP
- \fBfep-alias\fP \fIname\fP
- \fBfep-alias\fP \fIname string\fP
- .fi
- .RS
- The first form prints all aliases.
- The second form prints the alias for \fIname\fP.
- The last form set the alias for \fIname\fP to \fIstring\fP.
- .PP
- If you use
- .I fep
- without \fIauto-tty-fix\fP, following alias could be usefull.
- .if t .sp .3v
- .if n .sp 1
- .nf
- \h'\w'MMMMM'u'if\ $command\ ==\ sh
- \h'\w'MMMMMMMMMM'u'fep-alias\ more\ "fep-command\ more"
- \h'\w'MMMMMMMMMM'u'fep-alias\ vi\ "fep-command\ vi"
- \h'\w'MMMMM'u'endif
- .fi
- .if t .sp .3v
- .if n .sp 1
- .RE
- .IP "\fBfep-unalias\fP \fIlist\fP"
- Remove alias for each name in \fIlist\fP.
- .IP "\fBfep-set\fP \fIvariable = value\fR"
- Set a variable of \fIfep\fP to some value.
- .IP "\fBfep-unset\fP \fIvariable\fR"
- Unset a variable.
- .PP
- \fBfep-cd\fP [ \fIdirectory\fR ]
- .br
- \fBfep-chdir\fP [ \fIdirectory\fR ]
- .RS
- Change directory.
- It sometimes happens that a child process has changed directory,
- but
- .I fep
- is still in the old directory.
- In such a case, neither \fIlist-file-name\fR nor \fIexpand-file-name\fR
- will function as expected.
- This command allows you to change
- .IR fep 's
- current working directory (default = home directory).
- .RE
- .IP "\fBfep-pwd\fP"
- Print
- .IR fep 's
- current working directory.
- .IP "\fBfep-history\fP [ \fInumber of line\fR ]"
- Show the history of commands under
- .IR fep .
- .IP "\fBfep-echo\fP \fIarguments\fR"
- Only print the arguments.
- Variable names can be used prefixed by the "$" character.
- .IP "\fBfep-source\fP \fIfile\fR"
- Read the specified file and execute it.
- The contents of the file are not sent to sub-processes.
- .IP "\fBfep-save-history\fP [ \fInumber of lines to save\fR ] \fIfile\fR"
- Save the current history buffer in the specified file.
- .IP "\fBfep-read-history\fP [ \fIfile\fR ]"
- Read in the command history from the specified file.
- The default file is the value of the \fIhistory-file\fP variable.
- This file name is understood as a path relative to the home directory.
- If you want to specify the name relative to the current directory instead,
- prefix the path by "./".
- .PP
- .nf
- \fBfep-command\fP \fIcommand\fP
- \fBfep-!\fP \fIcommand\fP
- .fi
- .RS
- Execute \fIcommand\fP.
- .RE
- .IP "\fBquit-fep\fP"
- Kill the sub-process and exit.
- .PP
- .IP \fBfep-suspend\fP
- Suspend
- .I fep
- itself.
- In the unlikely possibility that
- .I fep
- falls into a dead-lock in which
- the sub-processes have stopped but
- .I fep
- is still running,
- use one of these commands to escape from the situation.
- .PP
- .nf
- \fBfep-read-from-file\fP \fIfile\fP
- \fBfep-<\fP \fIfile\fP
- .fi
- .RS
- Read data from specified file and send them to sub-process.
- The sub-process will read the data from the file as if they are typed
- at the keyboard.
- .RE
- .PP
- .nf
- \fBfep-read-from-command\fP \fIcommand\fP
- \fBfep-<!\fP \fIcommand\fP
- .fi
- .RS
- Send output of specified command to sub-process.
- .RE
- .PP
- .nf
- \fBfep-start-script [ \fIscript-file\fP ]
- \fBfep-script [ \fIscript-file\fP ]
- .fi
- .RS
- Start to send input and output to a script file.
- If \fIscript-file\fP is specified, it is used.
- If not the value of the variable \fIscript-file\fP will be used.
- .RE
- .PP
- .nf
- \fBfep-stop-script\fP
- .fi
- .RS
- Stop scripting.
- .RE
- .IP "\fBfep-show-bind\fP"
- Print current binding information.
- .IP "\fBfep-repaint\fP [ \fIline\fP ]"
- Repaint last output from command to screen.
- ``\fIline\fP'' specifies number of lines to repaint
- (default is screenful maximum). See also ``\fIauto-repaint\fP'' and
- ``\fIclear-repaint\fP'' variables.
- .RE
- .PP
- .B Control structures
- .RS 3n
- .PP
- .nf
- \fBfep-if\fP \fIexpression\fP
- \fBfep-elseif\fP \fIexpression\fP
- \fBfep-else\fP
- \fBfep-endif\fP
- .fi
- .RS
- Only four control structures are supported but that seems enough.
- .I Expression
- allows only the two operators "==" and "!=".
- .ce 0
- Variables can be referenced by prefixing with the "$" character.
- .RE
- .RE
- .PP
- Note:
- The "\fIfep-\fR" prefix of the built-in functions and the above operators
- can be abbreviated in commands that
- .I fep
- executes from a file.
- .RE
- .PP
- .\" ------------------------------------------------------------ Comment
- .B Comment
- .PP
- Lines starting with the character "#" are ignored by
- .IR fep .
- If
- .I fep
- encounters a comment in interaction, it is sent to the sub-process.
- In reading from a file, comments will merely be ignored.
- .PP
- .\" ------------------------------------------------------------ Variables
- .B Variables
- .PP
- .I Fep
- uses some variables.
- .RS 3n
- .ta 3i
- .IP "\fBeditmode\fP default: emacs"
- This variable defines the mode for command line editing.
- Key bindings will be set for the appropriate defaults
- when this variable is changed.
- .I Fep
- first looks at the environment variable
- .IR EDITMODE ,
- then looks at any command line arguments,
- and finally reads in the
- .I .feprc
- start-up file.
- .IP "\fBexpand-tilde\fP default: on"
- .I Fep
- expands "~" to the real home directory name by the expand-file-name function
- when this variable is set.
- .IP "\fBignore-empty-line\fP default: on"
- If this variable is set, empty command lines are not saved in the history file.
- .IP "\fBignore-same-line\fP default: on"
- If this variable is set,
- command lines identical to the previous command line
- are not saved to the history file.
- .IP "\fBalarm-on-eof\fP default: off"
- If this variable is set
- AND the function send-eof is not bound to the eof character
- AND the variable ignore-eof is not set,
- an alarm message will be displayed once
- the first time eof is encountered on an empty line.
- .IP "\fBhistory\fR default: 100"
- .I Fep
- maintains a history file of the length specified by this variable.
- .IP "\fBsavehist\fR default: off"
- If
- .I savehist
- is set
- .I fep
- saves the number of history entries specified by
- value of this variable in the file named in the variable
- .I history-file
- on terminating.
- .IP "\fBhistory-file\fP default: .fephistory"
- Contains the name of the history file for reading from and writing to.
- If the file described by this variable exists,
- .I fep
- will read the file into the history buffer on start up
- and then save the current session's history when it exits.
- .IP "\fBshowhist\fR default: terminal size"
- This variable specifies the number of history lines to be displayed by the
- .I show-history
- function.
- .IP "\fBignore-eof\fP default: off"
- .I Fep
- never worries about the eof character if this variable is set.
- .IP "\fBnoalias\fP default: off"
- If set, command aliasing won't be done.
- .IP "\fBcrt\fP default: terminal size"
- If set, more message is shown during printing the key bindings
- on each number of line specified by this variable.
- .IP "\fBcommand\fP default: \fIcommand-name\fR"
- .I Fep
- set this variable to the command name of the sub-process when it starts up.
- .IP "\fBshell\fR default: /bin/sh"
- Describe the command name to be invoked by
- .IR invoke-shell .
- .IP "\fBauto-tty-fix\fP default: on"
- If this variable is set,
- .I fep
- looks at the tty mode of the sub-command,
- and if the tty mode has changed,
- .I fep
- fixes the tty mode of standard out and
- sets the transparency flag according to the mode.
- If this variable is not set, the automatic tty mode check is not done,
- so you have to change the tty mode and transparency explicitly using the
- \fItoggle-transparency\fP function.
- .IP "\fBtty-fix-bell\fP default: off"
- If this variable is set,
- .I fep
- rings the bell when the tty mode is changed.
- .IP "\fBscript-file\fP default: fepscript"
- This variable is used by the
- .I fep-start-script
- command and by the
- .I start-script
- function.
- .IP "\fBdelimiters\fP default: SPACE & TAB"
- The contents of this variable are treated as delimiting characters for
- file name expantion and file name list.
- .IP "\fBauto-repaint\fP default: off"
- If this variable is set, \fIfep\fP automatically repaints the screen
- after restarting.
- .IP "\fBclear-repaint\fP default: off"
- If this variable is set, \fIfep\fP clears the screen before repainting.
- .IP "\fBprompt\fP default: see below"
- .I Fep
- outputs a prompt after executing built-in functions.
- The default string is set to the NULL string,
- but there are some default prompt strings for some common commands such as
- .I sh, dbx, lpc, mail, "sendmail -bt"
- and
- .I calc.
- However, since
- .I fep
- doesn't care about what program is running,
- the same prompt is still output when you are executing
- .I bc
- from
- .IR sh .
- .br
- You can change the value of prompt and other variables in the start-up file
- as follows:
- .if t .sp .3v
- .if n .sp 1
- .RS
- .DT
- .nf
- \h'\w'MMMMM'u'if $command == sh
- \h'\w'MMMMMMMMMM'u'set prompt = "$ "
- \h'\w'MMMMM'u'endif
- .fi
- .RE
- .RE
- .PP
- .B Start-Up File
- .PP
- .I Fep
- executes the file ".feprc" in the home directory of the user
- if it is found there when starting up.
- It looks for arguments on the command line first,
- and only then reads the ".feprc" file,
- so the file has higher priority.
- .PP
- .B "Functions"
- .PP
- .ta \w'delete-previous-character\ \ \ 'u
- .RS
- .nf
- abort Abort function
- backward-Word Backward word (non-space)
- backward-character Backward character
- backward-word Backward word (alpha-numeric)
- beginning-of-line Jump to beginning of line
- clear-screen Clear screen
- delete-line Delete whole line
- delete-next-Word Delete next word (non-space)
- delete-next-character Delete next character
- delete-next-word Delete next word (alpha-numeric)
- delete-previous-Word Delete previous word (non-space)
- delete-previous-character Delete previous character
- delete-previous-word Delete previous word (alpha-numeric)
- delete-to-kill-buffer Delete resion to buffer
- end-of-line Jump to end of line
- end-script End script
- expand-file-name Expand file name
- fix-transparency Check tty and change transparency mode
- forward-Word Forward word (non-space)
- forward-character Forward character
- forward-to-end-of-Word Forward to end of word (non-space)
- forward-to-end-of-word Forward to end of word (alpha-numeric)
- forward-word Forward word (alpha-numeric)
- help Show help
- ignore Ignore
- insert-and-flush Insert the character and flush buffer
- insert-tab Insert tab
- invoke-shell Invoke shell process
- kill-to-end-of-line Delete current position to eol
- kill-to-top-of-line Delete tol to current position
- list-file-name List file name
- literal-next Treat next character as literal
- mark Mark position
- new-line Insert newline
- next-history Get next history
- previous-history Get previous history
- repaint Repaint screen
- reprint Reprint line
- search-forward Search forward last !history
- search-reverse Search backward last !history
- self-insert Insert the character
- send-eof Send eof
- show-bindings Show binding table
- show-history Show history
- start-script Start script
- suspend Suspend fep
- terminate Terminate fep
- toggle-transparency Change transparency mode
- vi-c Vi c? commands
- vi-d Vi d? commands
- vi-edit Vi edit commands
- vi-ins-edit Vi insert mode
- vi-motion Vi cursor motion commands
- vi-new-line Vi new line
- vi-num Vi prefix number
- yank-from-kill-buffer Yank from kill buffer
- .fi
- .RE
- .PP
- Probably only the function name "\fItoggle-transparency\fR"
- is hard to understand.
- This function is provided for entering non-line-oriented tools
- from a line-oriented tool using
- .IR fep .
- Assume a situation where you are using
- .IR sh (1)
- with
- .IR fep ,
- and then invoke
- .IR vi (1).
- Since
- .I fep
- intercepts all input for editing,
- .I vi
- cannot work correctly.
- You can escape from this annoying situation using the
- "\fItoggle-transparency\fR" function which is bound to the
- .I Control-^
- key by default.
- Of course, it is also necessary to return to the normal mode after exiting vi.
- .PP
- Note, however, that this tty mode fix can also be done automatically.
- If the
- .I auto-tty-fix
- variable is set,
- .I fep
- looks at the tty mode of the sub-command and fixes the tty mode of standard
- input accordingly.
- .SH "OTHERS"
- .PP
- .I Fep
- can handle SHIFT-JIS kanji code if compiled with the -DKANJI flag.
- .SH "SEE ALSO"
- newcsh(1)
- .SH COPYRIGHT
- Copyright (c) 1987, 1988 by Software Research Associates, Inc.
- .br
- Distribution without fee is allowed as long as
- all copyright notices are included.
- .SH AUTHOR
- K. Utashiro
- .br
- Software Research Associates, Inc., Japan.
- .RS
- .nf
- .ta \w'JUNET: 'u
- UUCP: kddlab!srava.sra.junet!utashiro
- ARPA: utashiro%sra.junet@uunet.uu.net
- JUNET: utashiro@sra.junet
- .fi
- .RE
- .SH FILES
- .ta \w'~/.feprc,\ ./.feprc\ \ \ 'u
- .nf
- \^~/.feprc,\ ./.feprc start-up file
- \^~/.fephistory default history file
- \^./fepscript default script file
- .fi
- .SH BUGS
- .PP
- While working on the program the author sometimes lost his mind,
- whereupon so did the program.
- \End\Of\File\
- else
- echo "will not over write ./fep.1"
- fi
- echo "Finished archive 5 of 5"
- exit
-
-